package com.skt.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skt.common.annotation.Log;
import com.skt.common.core.controller.BaseController;
import com.skt.common.core.domain.AjaxResult;
import com.skt.common.enums.BusinessType;
import com.skt.manage.domain.HealthProfiles;
import com.skt.manage.service.IHealthProfilesService;
import com.skt.common.utils.poi.ExcelUtil;
import com.skt.common.core.page.TableDataInfo;

/**
 * 健康档案Controller
 * 
 * @author ffbaby
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/manage/profiles")
public class HealthProfilesController extends BaseController
{
    @Autowired
    private IHealthProfilesService healthProfilesService;

    /**
     * 查询健康档案列表
     */
//    @PreAuthorize("@ss.hasPermi('manage:profiles:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthProfiles healthProfiles)
    {
        startPage();
        List<HealthProfiles> list = healthProfilesService.selectHealthProfilesList(healthProfiles);
        return getDataTable(list);
    }

    /**
     * 导出健康档案列表
     */
    @PreAuthorize("@ss.hasPermi('manage:profiles:export')")
    @Log(title = "健康档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthProfiles healthProfiles)
    {
        List<HealthProfiles> list = healthProfilesService.selectHealthProfilesList(healthProfiles);
        ExcelUtil<HealthProfiles> util = new ExcelUtil<HealthProfiles>(HealthProfiles.class);
        util.exportExcel(response, list, "健康档案数据");
    }

    /**
     * 获取健康档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:profiles:query')")
    @GetMapping(value = "/{profileId}")
    public AjaxResult getInfo(@PathVariable("profileId") Long profileId)
    {
        return success(healthProfilesService.selectHealthProfilesByProfileId(profileId));
    }

    /**
     * 新增健康档案
     */
    @PreAuthorize("@ss.hasPermi('manage:profiles:add')")
    @Log(title = "健康档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthProfiles healthProfiles)
    {
        return toAjax(healthProfilesService.insertHealthProfiles(healthProfiles));
    }

    /**
     * 修改健康档案
     */
    @PreAuthorize("@ss.hasPermi('manage:profiles:edit')")
    @Log(title = "健康档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthProfiles healthProfiles)
    {
        return toAjax(healthProfilesService.updateHealthProfiles(healthProfiles));
    }

    /**
     * 删除健康档案
     */
    @PreAuthorize("@ss.hasPermi('manage:profiles:remove')")
    @Log(title = "健康档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{profileIds}")
    public AjaxResult remove(@PathVariable Long[] profileIds)
    {
        return toAjax(healthProfilesService.deleteHealthProfilesByProfileIds(profileIds));
    }
}
